<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
    String shebeitype = request.getParameter("shebeitype");
 %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">   
<html>
  <head>
    <base target="_self"/>
	<%@ include file="../jslib/jquerylib.jsp" %> 
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/web/style/layout.css" />
    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/jquery.validate.min.js"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js"  defer="defer"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/jquery.form.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/additional-methods.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/default/easyui.css" />
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/icon.css" />
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/demo.css" />
	<script type="text/javascript" src="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath() %>/jslib/lhgdialog/lhgcore.lhgdialog.min.js?skin=mac"></script>
		<script type="text/javascript">
            var selectId = "" ;
            var actionUrl='';
            $(document).ready(function(){
            	//高级搜索需要的js
				buttonStatus=1;
				$("#flip").click(function(){
					if(buttonStatus==1){
						$("#panel").slideToggle("slow");
						$("#flip").toggleClass("btnStatus2");
						buttonStatus=1;
					}
					else{
						$("#panel").slideUp("slow");
						$("#flip").toggleClass("btnStatus2");
					}
			 });
               $("#gridTable").jqGrid({
						url:'<%=request.getContextPath() %>/applyAction!queryEquipmentList.action',
						datatype: "json",
						height: 450,
						width: 710, 
						autowidth: true, 
						colNames:['ID','设备名称','设备编号','预计使用年限','购进日期','固定资产编号','单位','原值','监管期起始日期','监管期结束日期','部门'],
						colModel:[
								{name:'ID',index:'ID', width:60, key:true,hidden:true,hidedlg:true}, 
								{name:'EQUIPMENT_NAME',index:'EQUIPMENT_NAME', width:100},								
								{name:'EQUIPMENT_NO',index:'EQUIPMENT_NO', width:100},
								{name:'EQU_YJSYNX',index:'EQU_YJSYNX', width:110},
								{name:'EQU_GJ_DATE',index:'EQU_GJ_DATE', width:100},
								{name:'EQUIPMENT_GDZCBH',index:'EQUIPMENT_GDZCBH', width:50},
								{name:'EQUIPMENT_DW',index:'EQUIPMENT_DW', width:110},
								{name:'EQU_YZHI',index:'EQU_YZHI', width:110},
								{name:'EQUIPMENT_JGQQSRQ',index:'EQUIPMENT_JGQQSRQ', width:50},
								{name:'EQUIPMENT_JGQJSRQ',index:'EQUIPMENT_JGQJSRQ', width:50},
								{name:'EQU_ORG_NAME',index:'EQU_ORG_NAME', width:50}
						],   
					shrinkToFit:false,
					sortname:'id',
					sortorder:'desc',
					viewrecords:true,
					multiselect: true, // 是否显示复选框
					multiboxonly : true, 
					//gridview: true,  //提升速度
					rownumbers: true,//显示行号
					rownumWidth: 30, //行号的宽度
					rowNum:15,
					rowList:[15,20,50,200,500],
					toolbar: [false,"top"],
					loadComplete: function() {
						
					},
					jsonReader: {
						root:"rows",		// 数据行（默认为：rows）
						page: "page",  	// 当前页
						total: "total",  // 总页数
						records: "records",  // 总记录数
						repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设
					},
					prmNames:{rows:"rows",page:"page",sort:"sidx",order:"sord",search:"search"},
					pager:"#gridPager",
					caption: "设备列表"
			});
			    $("#consoleDlg").dialog({
			        autoOpen: false,      
			        modal: true,    // 设置对话框为模态（modal）对话框  
			        resizable: true,      
			        width: 700,  
			        buttons: {  // 为对话框添加按钮  
			            "关闭": function() {$("#consoleDlg").dialog("close")}
			        }  
			    }); 
				 jQuery("#gridTable").jqGrid('navGrid','#gridPager',{add:false,edit:false,del:false,search:false,refresh:false});
					jQuery("#gridTable").jqGrid('navButtonAdd','#gridPager',
								{ 	
								caption: "",                          
								onClickButton : function (){                               
								jQuery("#gridTable").jqGrid('setColumns');                           
								}
					}); 
								doResize(); 
		}); 
	
	//执行大小
	function doResize() { 
		var ss = getPageSize(); 
		//alert(ss.WinH);
		
			 $("#gridTable").jqGrid('setGridHeight', ss.WinH-245);
			 $("#gridTable").jqGrid('setGridWidth', ss.WinW-30); 
	} 
		
		
			function entryData(){
				 var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
				if (!ids) {
				    alert("请先选择记录!");  
				    return false;  
				}else{
					$.ajax({  
					        url : "<%=request.getContextPath() %>/applyAction!saveEqu.action?flag=0&appid=<%=request.getParameter("appid")%>&ids="+ids,
					        type : "post", 
					        //data : params,  
					        dataType : "json",  
					        cache : false,  
						    error : function(textStatus, errorThrown) {  
						        alert("系统ajax交互错误: " + textStatus.value);  
						    },  
						    success : function(data, textStatus) {  
				            	if(data.result=="success"){
					        		//alert("保存成功！");  
					        		window.close();  
					        	}else if(data.result=="error"){
					        		//alert("保存失败！"); 
					        		window.close();  
					        	}
						    }  
				        });
				} 
			}
			
			function centerClose(){
				window.close();
			}
             //查询
            function gridSearch(){
                var EQUIPMENT_NAME = $.trim($("#EQUIPMENT_NAME").val());
                var EQUIPMENT_NO = $.trim($("#EQUIPMENT_NO").val());
			    var params = {
			        "EQUIPMENT_NAME" : encodeURIComponent($.trim(EQUIPMENT_NAME)),
			        "EQUIPMENT_NO" : encodeURIComponent($.trim(EQUIPMENT_NO))
			    };
			    var postData = $("#gridTable").jqGrid("getGridParam", "postData");
			    $.extend(postData, params);  //(9)将postData中的查询参数覆盖为空值
			    $("#gridTable").jqGrid('setGridParam',
			    {
			         url:'<%=request.getContextPath()%>/applyAction!queryEquipmentList.action?shebeitype='+<%=shebeitype%>
			    }).trigger("reloadGrid", [{page:1}]); 
            }     
            
            //清空按钮  
           function resetquery()
           {
             jQuery("#EQUIPMENT_NAME").val('');
             jQuery("#EQUIPMENT_NO").val('');
           }
    </script>

	</head>


	<body>
		<form action="" id="form1" method="post">
			<table  cellspacing="1" cellpadding="1"  width="100%">
				 <tr>
				     <td colspan="2">
						<table width="100%" border="0" cellspacing="0" cellpadding="0" class="font12Black_B">
							<tr>
								<td  align="center">设备名称：</td>
								<td  align="left"><input type="text" id="EQUIPMENT_NAME" name="EQUIPMENT_NAME" value="" class="search_InputText"/></td>
								<td  align="center">设备编号：</td>
								<td  align="left">
								    <input type="text" id="EQUIPMENT_NO" name="EQUIPMENT_NO" value="" class="search_InputText"/>
								</td>
							    <td align="left"> 
							    <input id="query" type="button" class="search_Btn" value="查 询"  onclick="gridSearch()" />&nbsp;&nbsp;
								<input type="button" class="search_Btn" value="清 空"  onclick="resetquery()" /></td>
							</tr>
						</table>
						 <div id="panel" style="display:none" >
				            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="font12Black_B">	
							</table>
							</div>
						</td>
				     </tr>
				 <tr>
			        <td colspan="2" align="right" height="9" class="sclinebotBg"></td>
			     </tr>
			</table>

			<table style="width: 100%;" class="tableCont">
				<tr>
					<td>
						<input id="entry" type="button" value="确定" onclick="entryData()" class='button_b'/>
						<input id="center" type="button" value="取消" onclick="centerClose()" class='button_b'/>
					</td>
				</tr>
				<tr>
					<td colspan="4" style="padding-top:8px;">
						<table id="gridTable"></table>
						<div id="gridPager"></div>
					</td>
				</tr>
			</table>
		</form>
	</body>
</html>
